package com.lifp.exception.handler;

import com.lifp.vo.Result;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description 重写404错误处理
 * @Author lifp
 * @Version 1.0
 */
@Controller
public class ResourceNotFoundHandler implements ErrorController {
    @Override
    public String getErrorPath() {
        return "/error";
    }

    @RequestMapping("/error")
    @ResponseBody
    public Result handleError(HttpServletRequest request){
        return Result.failedWith(404,"资源不存在",null);
    }
}